package com.ruoyi.framework.aspectj;

import com.ruoyi.common.annotation.Anonymous;
import lombok.extern.java.Log;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import java.lang.reflect.Method;

public abstract class BaseAspect {
    protected static final ThreadLocal<Long> TIME_THREADLOCAL = new ThreadLocal<>();

    /**
     * 判断是否为匿名方法
     */
    protected boolean isAnonymousMethod(JoinPoint joinPoint) {
        MethodSignature signature = (MethodSignature) joinPoint.getSignature();
        Method method = signature.getMethod();

        // 检查方法级别注解
        if (method.isAnnotationPresent(Anonymous.class)) {
            return true;
        }

        // 检查类级别注解
        Class<?> targetClass = joinPoint.getTarget().getClass();
        return targetClass.isAnnotationPresent(Anonymous.class);
    }

}

